package org.monkey.common.constant.config;

import java.io.File;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import lombok.extern.slf4j.Slf4j;
import org.monkey.common.constant.util.ItemReject;
public class CommonConstant {
  private static final String URL_SPLIT = "/";
  public static final String EMPTY_STRING = "";
  public static final String DEFAULT_SOCKET_NAMESPACE = "DEFAULT";
  public static final ThreadPoolExecutor ITEM_POOL = new ThreadPoolExecutor(20, 100,
      5 * 60 * 1000L, TimeUnit.MILLISECONDS,
      new LinkedBlockingQueue<>(3000), r -> {
    Thread thread = new Thread(r);
    thread.setName("system_item_" + System.currentTimeMillis());
    return thread;
  },new ItemReject());
  public static String CONSTANT_PATH;
  static {
    String osName = "os.name";
    String win = "win";
    if (System.getProperty(osName).toLowerCase().contains(win)) {
      CONSTANT_PATH = "D:/tmp/tmpData";
    } else {
      CONSTANT_PATH = "/tmp/tmpData";
    }
    File file = new File(CONSTANT_PATH);
    if(!file.exists()){
      file.mkdirs();
    }
  }
}
